package kjj.android.ch7.app;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;

public class MyService extends Service {
	private final static String TAG = "MYKJJ service";

	// usually return an interface defined by aidl
	@Override
	public IBinder onBind(Intent intent) {
		Log.i(TAG, "MY service onBind() -----------------------------");
		return null;
	}

	@Override
	public void onCreate() {
		Log.i(TAG, "MY service onCreate() -----------------------------");
		super.onCreate();
	}
	
	@Override
	public void onStart(Intent intent, int startId){
		Log.i(TAG, "MY service onStart() -----------------------------");
		super.onStart(intent, startId);
		Toast.makeText(
				getApplicationContext(), 
				"Service is started.", 
				Toast.LENGTH_LONG
				).show();
	}
	
	@Override
	public void onDestroy(){
		Log.i(TAG, "MY service onDestroy() -----------------------------");
		super.onDestroy();
		Toast.makeText(
				getApplicationContext(), 
				"Service is destroyed.", 
				Toast.LENGTH_LONG
				).show();
	}

}
